<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>订单列表</title>
    <link rel="stylesheet" type="text/css" href="css/aui.css" />
		<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<body>
    <div class="order-header">
      <div class="order-user">
        <span>当前就诊人</span>
        <em id="my_em"></em>
        <i class="arrow-down"></i>
      </div>
      <div class="order-sub">
        <span>仅提供查询近180天订单</span>
      </div>
    </div>

    <div class="order-list">

    </div>


    <div class="order-layer" style="display:none;">
      <div class="order-layer-title">
        <h4>选择就诊人</h4>
        <i class="aui-iconfont aui-icon-close order-layer-close"></i>
      </div>
      <div class="order-layer-body">

      </div>
    </div>
</body>
<script src="js/jquery.min.js"></script>
<script src="layer/layer.js"></script>
<script type="text/javascript">
$('.order-user').click(function () {
  var name = $(this).find('i').attr('class');
  if(name=='arrow-down'){
    $(this).find('i').removeClass('arrow-down');
    $(this).find('i').addClass('arrow-up');
    layer.open({
      type: 1,
      anim: 2,
      title: false,
      closeBtn: false,
      offset: 'b',
      area: ['100%','330px'],
      shadeClose: true,
      content: $('.order-layer'),
      end: function(index, layero){
        $('.order-user').find('i').addClass('arrow-down');
        $('.order-user').find('i').removeClass('arrow-up');
      }
    });
  }
  else if(name=='arrow-up'){
    $(this).find('i').addClass('arrow-down');
    $(this).find('i').removeClass('arrow-up');
  }
})

$('.order-layer-close').click(function functionName() {
  layer.closeAll();
})
    var openid = localStorage.getItem("openid");
    $.ajax({
      type: "post",
      url: "http://guowang.nat300.top/wechat114/thepatients/selectByopenid",
      data:{"openid":openid},
      async:false,
      dataType: "json",
      success: function (data) {
        var str = "";
        for (var i=0;i<data.data.length;i++){
          str += "<div class=\"order-layer-user\">\n" +
                  "          <div class=\"order-layer-info\">\n" +
                  "            <h4>"+data.data[i].thepatientname+"</h4>\n" +
                  "            <p>"+data.data[i].idnum+"</p>\n" +
                  "            <input type='hidden' value='"+data.data[i].mobilenum+"'>\n" +
                  "          </div>\n" +
                  "          <i class=\"aui-iconfont aui-icon-right\"></i>\n" +
                  "        </div>";
        }
        $('.order-layer-body').html(str)
        $('.order-layer-user').click(function() {
          $("#my_em").html($(this).children().find("h4").html())
          var phon = $(this).children().find("input").val()
          layer.closeAll();
            $.ajax({
                type: "post",
                url: "http://guowang.nat300.top/wechat114/registered/getRegistered",
                data:{"phon":phon},
                async:false,
                dataType: "json",
                success: function (data) {
                    var str2 = "";
                    var status = "未取号"
                    for (var i=0;i<data.data.length;i++){
                        if (data.data[i].status == "1"){
                            status = "已取号"
                        }
                        str2 += "<a class='order-item' href='detail.html?id="+data.data[i].id+"&name="+$("#my_em").html()+"'>\n" +
                            "        <div class=\"order-item-header\">\n" +
                            "          <h4>"+data.data[i].hospitalsid+"</h4>\n" +
                            "          <span>"+status+"</span>\n" +
                            "          <i class=\"aui-iconfont aui-icon-right\"></i>\n" +
                            "        </div>\n" +
                            "        <div class=\"order-item-body\">\n" +
                            "          <div class=\"order-item-row\">\n" +
                            "            <span>就诊科室</span>\n" +
                            "            <p>"+data.data[i].deptid+"</p>\n" +
                            "          </div>\n" +
                            "          <div class=\"order-item-row\">\n" +
                            "            <span>就诊时间</span>\n" +
                            "            <p>"+data.data[i].datetime+"</p>\n" +
                            "          </div>\n" +
                            "          <div class=\"order-item-row\">\n" +
                            "            <span>挂号证件</span>\n" +
                            "            <p>居民身份证</p>\n" +
                            "          </div>\n" +
                            "        </div>\n" +
                            "      </a>";
                    }
                    $('.order-list').html(str2)
                }
            })
        })
      }
    })
</script>
</html>
